from typing import List, Literal
from pydantic import Field, BaseModel


class _ElasticQuery(BaseModel):
    """自定义搜索"""
    query: dict = Field({'match_all': {}}, title='')
    agg: dict = Field({}, title='')
    source: List[str] = Field([], title='', alias='_source')


class PlatScope(BaseModel):
    """平台搜索范围"""
    model: List[str] = Field(None, title='')
    source: List[str] = Field(None, title='')


class PlatQuery(BaseModel):
    type: Literal['Custom', 'Visual'] = Field(..., title='')
    scope: PlatScope = Field(..., title='')
    search: _ElasticQuery = Field(..., title='')


class ProxyQuery(BaseModel):
    """三方搜索"""
    proxy_configure: dict = Field({}, title='代理配置')
    search_configure: dict = Field({}, title='搜索配置')
